Skip to content

Conversation

@akshayutture-augment
Copy link

…7534)

* Loki query splitting: interpolate queries before execution

* Update tests

* Prettier

* shardQuerySplitting: remove unnecessary call
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@akshayutture-augment
Copy link
Author

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Nov 14, 2025

Greptile Overview

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The changes are well-tested, logically sound, and represent a clean refactoring. The functionality shift from late to early interpolation is properly covered by new tests, and the implementation correctly uses the applyTemplateVariables method that already exists in the datasource. No logic errors, security issues, or breaking changes identified.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
public/app/plugins/datasource/loki/querySplitting.ts 5/5 Moved template variable interpolation to the start of query splitting process using applyTemplateVariables instead of later interpolation
public/app/plugins/datasource/loki/shardQuerySplitting.ts 5/5 Replaced interpolateVariablesInQueries batch method with per-query applyTemplateVariables calls for early interpolation
public/app/plugins/datasource/loki/querySplitting.test.ts 5/5 Added test case to verify template variables are interpolated before query execution
public/app/plugins/datasource/loki/shardQuerySplitting.test.ts 5/5 Updated mocks from interpolateVariablesInQueries to applyTemplateVariables and added new interpolation test

Sequence Diagram

sequenceDiagram
    participant User
    participant QuerySplitting as runSplitQuery/runShardSplitQuery
    participant Datasource
    participant Backend
    
    User->>QuerySplitting: Request with targets
    
    Note over QuerySplitting: Filter queries (!hide, has expr)
    
    loop For each query
        QuerySplitting->>Datasource: applyTemplateVariables(query, scopedVars, filters)
        Note over Datasource: Interpolate variables except<br/>__auto, __interval, __range<br/>(kept for backend)
        Datasource-->>QuerySplitting: Interpolated query
    end
    
    Note over QuerySplitting: Partition queries by type<br/>(logs vs metrics, direction, etc.)
    
    loop For each partition
        QuerySplitting->>Backend: runQuery(interpolated queries)
        Backend-->>QuerySplitting: Response
    end
    
    QuerySplitting-->>User: Combined responses
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants